package com.peanut.entity;


import com.peanut.constants.Status;

public class JsonResult {
	public int code;
	public String message;
	public Object data;
	
	
	public JsonResult(int code, String message, Object data) {
		this.code = code;
		this.message = message;
		this.data = data;
	}
	
	
	public int getCode() {
		return code;
	}
	
	public void setCode(int code) {
		this.code = code;
	}
	
	public String getMessage() {
		return message;
	}
	
	public void setMessage(String message) {
		this.message = message;
	}
	
	public Object getData() {
		return data;
	}
	
	public void setData(Object data) {
		this.data = data;
	}
	
	
	public static JsonResult success() {
		return new JsonResult(1000, "成功", null);
	}
	
	public static JsonResult success(String message) {
		return new JsonResult(1000, message, null);
	}
	
	public static JsonResult success(String message, Object data) {
		return new JsonResult(1000, message, data);
	}
	
	public static JsonResult success(Object data) {
		return new JsonResult(1000, "成功", data);
	}
	
	
	public static JsonResult fail() {
		return new JsonResult(2000, "操作失败", null);
	}
	
	public static JsonResult fail(int code) {
		return new JsonResult(code, "操作失败", null);
	}
	
	public static JsonResult fail(String message) {
		return new JsonResult(2000, message, null);
	}
	
	public static JsonResult fail(int code,String message) {
		return new JsonResult(code, message, null);
	}
	
	
	
	// 状态码
	public static JsonResult status(Status status){
		return new JsonResult(status.code,status.message,null);
	}
}
